package com.py.androidUtils.UI;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;

import com.py.androidUtils.base.BaseActivity;
import com.readyidu.app.R;

public class InstructionsActivity extends BaseActivity {
	private EditText instructionsInfo;
	private TextView textSize;
	private int totalNumber = 200;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.activity_instructions);
		getTitleActionBar().setImgLeft(R.drawable.icon_back, new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				finishactivity(InstructionsActivity.this);
			}
		});
		getTitleActionBar().setTitleBar("补充说明");
		getTitleActionBar().setTvRight1("提交", new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = getIntent();
				intent.putExtra("instructions", instructionsInfo.getText().toString());
				setResult(RESULT_OK, intent);
			}
		});

		instructionsInfo = (EditText) this.findViewById(R.id.instructionsInfo);
		textSize = (TextView) this.findViewById(R.id.textSize);

		instructionsInfo.addTextChangedListener(new TextWatcher() {
			@Override
			public void onTextChanged(CharSequence s, int start, int before, int count) {
			}

			@Override
			public void beforeTextChanged(CharSequence s, int start, int count, int after) {
			}

			@Override
			public void afterTextChanged(Editable s) {
				textSize.setText(String.valueOf(totalNumber - s.toString().trim().length()));
			}
		});
	}
}
